package LeetCode;

//
// Created by ✎﹏ℳ๓独赏☆独醉 on 2024/6/8.
//
//https://leetcode.cn/problems/single-number/description/
public class 只出现一次的数字 {
    public static void main(String[] args) {
        int[] nums = {1,1,2};
        System.out.println(singleNumber(nums));
    }
    public static int singleNumber(int[] nums) {
        if(nums.length == 1)return nums[0];
        int num = 0;
        for(int n : nums){
            num = num ^ n;
        }
        return num;
    }
}
